<?php

class Note extends Controller {

	function Note()
	{
		parent::Controller();	
		$this->load->scaffolding('notes');
	}
	
	/**
	 * Function called to retrieve a note.
	 * url controlled : /note/get/$id
	 *
	 * @access	public
	 * @return	void
	 */
	function get()
	{
		//print_r($this->uri) ;
		if($this->uri->segment(3, 0) > 0)
		{
			$this->load->model('NoteModel');
			$data['note'] = $this->NoteModel->getNote($this->uri->segment(3, 0));
			//print_r($data['note']);
			if($this->uri->segment(5, 0) !== FALSE)
			{
				$i = 0;
				foreach($data['note']->photos as $photo)
				{
					if($photo->id == $this->uri->segment(5, 0))
					{
						$data['photoNumberInSlider'] = $i;
						break;
					}
					$i++;
				}
			}
			$this->output->set_header('Content-type:text/xml; charset=utf-8'); // For Safari
			$this->load->view('note',$data);
		}
	}
	
	function insertComment(){
		$this->load->model('notemodel');
		$this->notemodel->insertComment();
	}
	
}

/* End of file note.php */
/* Location: ./system/application/controllers/note.php */
?>